download_jexus:
  cmd.run:
    - name: |
        cd /srv/files/
        wget http://erlang.org/download/otp_src_18.3.tar.gz
    - unless: test -f /srv/files/jexus-5.8.1-x64.tar.gz


install-jexus:
  archive.extracted:
    - name: /usr/
    - source: /srv/files/jexus-5.8.1-x64.tar.gz
    - tar_options: zxvf
    - archive_format: tar
    - if_missing: /usr/jexus/


/usr/jexus/siteconf/jexus-aspx:
  file.managed:
    - source: salt://jexus/files/jexus-aspx

/usr/jexus/siteconf/jexus-php:
  file.managed:
    - source: salt://jexus/files/jexus-php

jexus-service:
  cmd.run:
    - name: /usr/jexus/jws restart


{% if not salt["file.contains"]("/etc/rc.local", "jexus") %}
autostart:
  file.append:
    - name: /etc/rc.local
    - text: /usr/jexus/jws start
{% endif %}